function LineChart(chartDiv,title,yAxisName,type,startTime,endTime,dataMap){
	this.chartDiv = chartDiv;
	this.title = title;
	this.yAxisName = yAxisName;
	this.type=type;
	this.startTime=startTime;
	this.endTime = endTime;
	this.compareStartTime=startTime;
	this.compareEndTime = endTime;
	this.dataMap = dataMap;
	this.chartString = "";
	this.keyPattern ="";
	this.seriesNameArray ={};
	this.seriesKeyArray={};
	this.toCompare = false;
	this.seriesNameA ="";
	this.seriesNameB="";
};

LineChart.prototype.setKeyPattern = function(keyPattern){
	this.keyPattern = keyPattern;
};

LineChart.prototype.setCompareDateMap = function(compareDataMap){
	this.compareDataMap=compareDataMap;
	this.toCompare = true;
};

LineChart.prototype.setCompareStartTime = function(compareStartTime){
	this.compareStartTime=compareStartTime;
};

LineChart.prototype.setCompareEndTime = function(compareEndTime){
	this.compareEndTime = compareEndTime;
};

LineChart.prototype.setSeriesName = function(seriesNameA,seriesNameB){
	this.seriesNameA=seriesNameA;
	this.seriesNameB=seriesNameB;
};

LineChart.prototype.generateDataString = function(){
	this.chartString ="<chart caption='"+ this.title+"' baseFontSize='12' palette='3' YAxisName='"+ this.yAxisName+"' numdivlines='8' lineThickness='2' showValues='0' anchorRadius='3' anchorBgAlpha='50' numVDivLines='11' showAlternateVGridColor='1' alternateVGridAlpha='3' formatNumber='0' formatNumberScale='0' animation='1' numVisiblePlot='12'>";
	if(this.type=="day"){
		var FORMAT ="yyyy-MM-dd";
		var DAY = 24*60*60*1000;
		var startDate = Date.parse(this.startTime,FORMAT);
		var endDate = Date.parse(this.endTime,FORMAT);
		var start = startDate.valueOf();
		var end = endDate.valueOf();
		this.chartString+="<categories >";
	
		for(var time = start;time<=end;time+=DAY){
			var day = new Date();
			day.setTime(time);
			var key = day.format("MM-dd");
			this.chartString+="<category label='"+key+"' />";
		}
		this.chartString+="</categories>";
		var seriesLenght = this.seriesKeyArray.length;
		var showSeries = true;
		if(seriesLenght<1){
			showSeries = false;
		}
		for(var i = 0;i<seriesLenght;i++){
			this.chartString+="<dataset ";
			if(showSeries){
				var seriesName = this.seriesNameArray[i];
				if(seriesName === undefined){
					seriesName="";
				}
				this.chartString+="seriesName='"+this.seriesNameA+seriesName+"'";
			}
			this.chartString+=">";
			for(var time = start;time<=end;time+=DAY){
				var day = new Date();
				day.setTime(time);
				var key = this.keyPattern.replace("{0}",day.format(FORMAT));
				if(key.indexOf("{1}")>-1){
					key = key.replace("{1}",this.seriesKeyArray[i]);
				}
				var value = this.dataMap[key];
				if (value === undefined){
					value =0;
				}
	    		this.chartString+='<set value="'+value+'"/>';
			}
			this.chartString+="</dataset>";
		}
		this.chartString+="</chart>";
	}else{
		this.chartString+="<categories >";
		for(var time = start;time<=end;time++){
			this.chartString+="<category label='"+time+"' />";
		}
		this.chartString+="</categories>";
		this.chartString+="<dataset>";
		for(var time = start;time<=end;time+=DAY){
			var value = dataMap[time];
			if (value === undefined){
				value =0;
			}
    		this.chartString+='<set value="'+value+'"/>';
		}
		this.chartString+="</dataset>";
		this.chartString+="</chart>";
	}
};
LineChart.prototype.draw = function(seriesKeyArray,seriesNameArray){
	this.seriesKeyArray = seriesKeyArray;
	this.seriesNameArray = seriesNameArray;
	this.generateDataString();
	var chart = new FusionCharts("../static/FusionCharts/MSLine.swf", "LineChartId", "726", "325", "0", "0");
    chart.setXMLData(this.chartString);
    chart.render(this.chartDiv);
};